<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <style>
                fieldset{
                    margin-right: 15px;
                }
            </style>

            <h:form id="userForm" enctype="multipart/form-data">
                <p:panel id="usuarioPanel" styleClass="clearfix container_24 withoutBorder">
                    <h3 class="title">Usuario</h3>
                    <hr/>
                    <p:growl id="messages" showDetail="true" autoUpdate="true"  />

                    <p:panel id="userPanel" styleClass="container_24 clearfix withoutBorder">
                        <fieldset>
                            <legend>Cadastro</legend>

                            <p:outputLabel value="Nome:" styleClass="grid_3" for="nameInputText"/>
                            <p:inputText id="nameInputText" styleClass="grid_20" value="#{managerCriarUsuario.user.nome}" />

                            <p:outputLabel value="Cargo:" styleClass="grid_3" for="postInputText"/>
                            <p:inputText id="postInputText" styleClass="grid_20" value="#{managerCriarUsuario.user.post}" />

                        </fieldset>
                    </p:panel>

                    <p:panel id="loginPanel" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">
                        <fieldset>
                            <legend>Login</legend>
                            <p:outputLabel value="Login:" styleClass="grid_3" for="loginInputText"/>
                            <p:inputText id="loginInputText" styleClass="grid_8" 
                                         value="#{managerCriarUsuario.user.login}" 
                                         required="true" requiredMessage="O campo Login é obrigatório !"/>
                            <p:outputLabel style="color: #005A27" rendered="#{managerCriarUsuario.mensagemLogin}" styleClass="grid_6" value="login não está disponível !" />
 
                            <div class="clear"/>

                            <p:outputLabel value="Senha:" styleClass="grid_3" for="senhaPassword"/>
                            <p:password id="senhaPassword" styleClass="grid_8" value="#{managerCriarUsuario.user.senha}" 
                                        required="true" requiredMessage="O campo Senha é obrigatório !"
                                        promptLabel="Digite uma senha segura" weakLabel="Razoável"
                                        goodLabel="Boa" strongLabel="Excelente" feedback="true"/>
                            <div class="clear"/>

                            <p:outputLabel value="Repetir Senha:" styleClass="grid_4 senhaLabelUsuario" for="confirmPassword"/>
                            <p:password id="confirmPassword" styleClass="grid_8" value="#{managerCriarUsuario.confirm}" 
                                        required="true" requiredMessage="O campo Repetir Senha é obrigatório !"
                                        promptLabel="Digite uma senha segura" weakLabel="Razoável"
                                        goodLabel="Boa" strongLabel="Excelente" feedback="true"/>
                        </fieldset>
                    </p:panel>

                    <p:panel id="acessoPanel" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">
                        <fieldset>
                            <legend>Nível de Acesso</legend>
                            <p:pickList id="pickList" value="#{managerCriarUsuario.dualGrupo}" var="g" 
                                        converter="grupoconverter" itemLabel="#{g.descricao}" itemValue="#{g}" 
                                        showSourceFilter="true" showTargetFilter="true" 
                                        filterMatchMode="contains">

                                <f:facet name="sourceCaption">Disponíveis</f:facet>  
                                <f:facet name="targetCaption">Selecionados</f:facet>  
                            </p:pickList>

                        </fieldset>
                    </p:panel>
                    <br/>
                    <div class="buttonAction">
                        <p:commandButton value="Salvar" icon="ui-icon-disk"
                                         update="@form"
                                         actionListener="#{managerCriarUsuario.save()}"
                                         styleClass="ui-priority-primary" />
                        <p:button href="index.xhtml" value="Cancelar"  icon="ui-icon-trash" />
                    </div >
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
